/**
 * 
 */
package org.istt.service.impl;

import java.util.List;

import org.istt.dao.UserDao;
import org.istt.domain.User;
import org.istt.service.UserManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Huy
 *
 */
@Service("userManager")
public class UserManagerImpl extends ManagerImpl<User, Long> implements UserManager {
	/**
	 * @param categoryDao the categoryDao to set
	 */
	@Autowired
	public void setUserDao(UserDao dao) {
		this.dao = dao;
	}

	@Override
	public List<User> searchByUserName(String username) {
		return ((UserDao)dao).findByUserName(username);
	}
	
	@Override
	public List<User> searchUser(String username, String lastname, String firstname, Long departmentId, Long positionId) {
		if (departmentId == 0l) departmentId = null;
		if (positionId == 0l) positionId = null;		
		return ((UserDao)dao).findUser(username, lastname, firstname, departmentId, positionId);
	}

	@Override
	public List<User> findUserByDeptId(Long deptId) {
		return ((UserDao)dao).findUserByDeptId(deptId);
	}

	@Override
	public List<List<Object>> getUserGroupWfs(Long workflwProcessId) {
		return ((UserDao)dao).findUserGroupWfs(workflwProcessId);
	}	
	
	@Override
	public User login(String username, String password) {
		return ((UserDao)dao).login(username, password);
	}
	@Override
	public List<User> getUserByGroupWfs(Long workflwProcessId) {
		return ((UserDao)dao).findUserByGroupWfs(workflwProcessId);
	}
	
	@Override
	public boolean searchUserToDelete(final Long userId) {
		return ((UserDao)dao).searchUserToDelete(userId);
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.istt.service.UserManager#loadUsersByUsername(java.lang.String)
	 */
	@Override
	public List<User> loadUsersByUsername(String username) {
		return ((UserDao)dao).loadUsersByUsername(username);
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.istt.service.UserManager#loadUserAuthorities(java.lang.String)
	 */
	@Override
	public List<String> loadUserAuthorities(String username) {
		return ((UserDao)dao).loadUserAuthorities(username);
	}

}
